/**
 * Created with IntelliJ IDEA.
 * Description:
 * User:DELL
 * Time:23:20
 */
public class demo5 {
    public int minSubArrayLen(int target, int[] nums) {
        int ret=Integer.MAX_VALUE,len = nums.length,sum=0;
        for(int left=0,right=0;right<len;right++){
            sum+=nums[right];
            while(sum>=target){
                ret=Math.min(ret,right-left+1);
                sum-=nums[left++];
            }
        }
        return ret==Integer.MAX_VALUE?0:ret;
    }
}
